package com.rst.dao;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.rst.model.Book;
import com.rst.model.IssueBook;

@Repository
@Transactional
public class IssueBookDAO {

	@Autowired
	private SessionFactory sessionFactory;

	public void saveBook(Book book) {
		sessionFactory.getCurrentSession().saveOrUpdate(book);		
	}

	public Book getBookById(Long bookId) {
	    Session session = sessionFactory.getCurrentSession();
	    Book book = (Book)session.get(Book.class, bookId);
		return book;
	}

	public void saveIssueBook(IssueBook issueBook) {
		sessionFactory.getCurrentSession().saveOrUpdate(issueBook);		
	}

}




